﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data;
using System.Data.SqlClient;

namespace QLThuVien
{
    public class KTDN
    {
        string tendn = "", matkhau = "", quyenhan = "", manv = "", hoten = "", diachi = "";
        public KTDN() { }
        public KTDN(string tendn, string matkhau, string quyen, string manhanvien, string hoten, string diachi)
        {
            this.matkhau = matkhau;
            this.tendn = tendn;
            this.quyenhan = quyen;
            this.manv = manhanvien;
            this.hoten = hoten;
            this.diachi = diachi;
        }

        public void set_quyenhan(string qh)
        {
            this.quyenhan = qh;
        }
        public void set_manv(string manv)
        {
            this.manv = manv;
        }
        public void set_diachi(string diachi)
        {
            this.diachi = diachi;
        }
        public void set_hoten(string hoten)
        {
            this.hoten = hoten;
        }
        public void set_tendangnhap(string tendn)
        {
            this.tendn = tendn;
        }
        public void set_matkhau(string pw)
        {
            this.matkhau = pw;
        }

        public string get_quyenhan()
        {
            return quyenhan;
        }

        public string get_manv()
        {
            return manv;
        }
        public string get_matkhau()
        {
            return matkhau;
        }
        public string get_tendangnhap()
        {
            return tendn;
        }

        public string get_diachi()
        {
            return diachi;
        }

        public string get_hoten()
        {
            return hoten;
        }

        public void chonhanvien(string tendn, string matkhau)
        {
            Truyxuatdulieu txdl = new Truyxuatdulieu();
            SqlDataReader dr;
            SqlCommand sc = new SqlCommand("select MATKHAU,QUYENHAN,MANHANVIEN,DIACHI,HOTEN from nhanvien where nhanvien.TENDANGNHAP='" + tendn + "' and nhanvien.MATKHAU='" + matkhau + "'");
            dr = txdl.lay_reader(sc.CommandText);
            while (dr.Read())
            {
                this.matkhau = Convert.ToString(dr["MATKHAU"]);
                quyenhan = Convert.ToString(dr["quyenhan"]);
                manv = Convert.ToString(dr["MANHANVIEN"]);
                hoten = Convert.ToString(dr["HOTEN"]);
                this.tendn = tendn;
                diachi = Convert.ToString(dr["DIACHI"]);
            }                        
        }

        public void xoanhanvien()
        {
            matkhau = quyenhan = manv = hoten = diachi = "";
        }
       
    }
}
